<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libcoap: str.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">libcoap<span id="projectnumber">&#160;4.2.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.8 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function() { init_codefold(0); });
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('str_8h_source.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div class="header">
  <div class="headertitle"><div class="title">str.h</div></div>
</div><!--header-->
<div class="contents">
<a href="str_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span><span class="comment">/*</span></div>
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno">    2</span><span class="comment"> * str.h -- strings to be used in the CoAP library</span></div>
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno">    3</span><span class="comment"> *</span></div>
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno">    4</span><span class="comment"> * Copyright (C) 2010-2011 Olaf Bergmann &lt;bergmann@tzi.org&gt;</span></div>
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno">    5</span><span class="comment"> *</span></div>
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno">    6</span><span class="comment"> * This file is part of the CoAP library libcoap. Please see README for terms</span></div>
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno">    7</span><span class="comment"> * of use.</span></div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno">    8</span><span class="comment"> */</span></div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno">    9</span> </div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno">   10</span><span class="preprocessor">#ifndef COAP_STR_H_</span></div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno">   11</span><span class="preprocessor">#define COAP_STR_H_</span></div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno">   12</span> </div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno">   13</span><span class="preprocessor">#include &lt;string.h&gt;</span></div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno">   14</span> </div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno">   15</span> </div>
<div class="foldopen" id="foldopen00025" data-start="{" data-end="};">
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"><a class="line" href="structcoap__string__t.html">   25</a></span><span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code hl_struct" href="structcoap__string__t.html">coap_string_t</a> {</div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno"><a class="line" href="structcoap__string__t.html#adbca4bb782ba6046520f8608ef0f5a66">   26</a></span>  <span class="keywordtype">size_t</span> <a class="code hl_variable" href="structcoap__string__t.html#adbca4bb782ba6046520f8608ef0f5a66">length</a>;    </div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"><a class="line" href="structcoap__string__t.html#ad904e545a40c835079a1eb2dd230fb29">   27</a></span>  <a class="code hl_typedef" href="uthash_8h.html#aba7bc1797add20fe3efdf37ced1182c5">uint8_t</a> *<a class="code hl_variable" href="structcoap__string__t.html#ad904e545a40c835079a1eb2dd230fb29">s</a>;       </div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"><a class="line" href="group__string.html#ga9c24e196cb4b1f8171771445cfc3e8ce">   28</a></span>} <a class="code hl_struct" href="structcoap__string__t.html">coap_string_t</a>;</div>
</div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno">   29</span> </div>
<div class="foldopen" id="foldopen00033" data-start="{" data-end="};">
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"><a class="line" href="structcoap__str__const__t.html">   33</a></span><span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code hl_struct" href="structcoap__str__const__t.html">coap_str_const_t</a> {</div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"><a class="line" href="structcoap__str__const__t.html#acab2b62ad139aed3925d34cbf8e3fded">   34</a></span>  <span class="keywordtype">size_t</span> <a class="code hl_variable" href="structcoap__str__const__t.html#acab2b62ad139aed3925d34cbf8e3fded">length</a>;    </div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"><a class="line" href="structcoap__str__const__t.html#a9a80ea586c315c518bc345e83d9c852f">   35</a></span>  <span class="keyword">const</span> <a class="code hl_typedef" href="uthash_8h.html#aba7bc1797add20fe3efdf37ced1182c5">uint8_t</a> *<a class="code hl_variable" href="structcoap__str__const__t.html#a9a80ea586c315c518bc345e83d9c852f">s</a>; </div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"><a class="line" href="group__string.html#ga53b7b17631d12bf63ce9ff8fef192d6a">   36</a></span>} <a class="code hl_struct" href="structcoap__str__const__t.html">coap_str_const_t</a>;</div>
</div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno">   37</span> </div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"><a class="line" href="group__string.html#ga607f236d46eb2b285bbfaae7588cea10">   38</a></span><span class="preprocessor">#define COAP_SET_STR(st,l,v) { (st)-&gt;length = (l), (st)-&gt;s = (v); }</span></div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno">   39</span> </div>
<div class="foldopen" id="foldopen00043" data-start="{" data-end="};">
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"><a class="line" href="structcoap__binary__t.html">   43</a></span><span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code hl_struct" href="structcoap__binary__t.html">coap_binary_t</a> {</div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno"><a class="line" href="structcoap__binary__t.html#a259ade386451359049875d1d90447963">   44</a></span>  <span class="keywordtype">size_t</span> <a class="code hl_variable" href="structcoap__binary__t.html#a259ade386451359049875d1d90447963">length</a>;    </div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"><a class="line" href="structcoap__binary__t.html#a728a24b7e7a462954cdd7a1790c35a8e">   45</a></span>  <a class="code hl_typedef" href="uthash_8h.html#aba7bc1797add20fe3efdf37ced1182c5">uint8_t</a> *<a class="code hl_variable" href="structcoap__binary__t.html#a728a24b7e7a462954cdd7a1790c35a8e">s</a>;       </div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"><a class="line" href="group__string.html#ga7f8af507a2e35ddcd798e207c14300bf">   46</a></span>} <a class="code hl_struct" href="structcoap__binary__t.html">coap_binary_t</a>;</div>
</div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno">   47</span> </div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno">   56</span><a class="code hl_struct" href="structcoap__string__t.html">coap_string_t</a> *<a class="code hl_function" href="group__string.html#ga9862b1ade5e6e2eb01aabd0fa98b63e1">coap_new_string</a>(<span class="keywordtype">size_t</span> size);</div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno">   57</span> </div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno">   63</span><span class="keywordtype">void</span> <a class="code hl_function" href="group__string.html#gad991c87cfcf9b2414d2dc430c8701ed3">coap_delete_string</a>(<a class="code hl_struct" href="structcoap__string__t.html">coap_string_t</a> *<span class="keywordtype">string</span>);</div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno">   64</span> </div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno">   75</span><a class="code hl_struct" href="structcoap__str__const__t.html">coap_str_const_t</a> *<a class="code hl_function" href="group__string.html#gaac769e3d5cea5481436c9eb3cb28d92a">coap_new_str_const</a>(<span class="keyword">const</span> <a class="code hl_typedef" href="uthash_8h.html#aba7bc1797add20fe3efdf37ced1182c5">uint8_t</a> *data, <span class="keywordtype">size_t</span> size);</div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno">   76</span> </div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno">   82</span><span class="keywordtype">void</span> <a class="code hl_function" href="group__string.html#ga4c283744d0fa51b553bf3fc52488e4b0">coap_delete_str_const</a>(<a class="code hl_struct" href="structcoap__str__const__t.html">coap_str_const_t</a> *<span class="keywordtype">string</span>);</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno">   83</span> </div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno">   93</span><span class="preprocessor">#ifdef __cplusplus</span></div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno">   94</span><span class="keyword">namespace </span>libcoap {</div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno">   95</span>  <span class="keyword">struct </span>CoAPStrConst : <a class="code hl_struct" href="structcoap__str__const__t.html">coap_str_const_t</a> {</div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno">   96</span>    <span class="keyword">operator</span> <a class="code hl_struct" href="structcoap__str__const__t.html">coap_str_const_t</a> *() { <span class="keywordflow">return</span> <span class="keyword">this</span>; }</div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno">   97</span>  };</div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno">   98</span>}</div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno">   99</span><span class="preprocessor">#define coap_make_str_const(CStr)                                       \</span></div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno">  100</span><span class="preprocessor">  libcoap::CoAPStrConst{sizeof(CStr)-1, reinterpret_cast&lt;const uint8_t *&gt;(CStr)}</span></div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno">  101</span><span class="preprocessor">#else </span><span class="comment">/* __cplusplus */</span><span class="preprocessor"></span></div>
<div class="foldopen" id="foldopen00102" data-start="" data-end="">
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno"><a class="line" href="group__string.html#ga3a9d1f377dc7a25aa8b6136a169f76c1">  102</a></span><span class="preprocessor">#define coap_make_str_const(string)                                     \</span></div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno">  103</span><span class="preprocessor">  (&amp;(coap_str_const_t){sizeof(string)-1,(const uint8_t *)(string)})</span></div>
</div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno">  104</span><span class="preprocessor">#endif  </span><span class="comment">/* __cplusplus */</span><span class="preprocessor"></span></div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno">  105</span> </div>
<div class="foldopen" id="foldopen00115" data-start="" data-end="">
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno"><a class="line" href="group__string.html#ga7f43c10b486dc6d45c37fcaf987d711b">  115</a></span><span class="preprocessor">#define coap_string_equal(string1,string2) \</span></div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno">  116</span><span class="preprocessor">        ((string1)-&gt;length == (string2)-&gt;length &amp;&amp; ((string1)-&gt;length == 0 || \</span></div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno">  117</span><span class="preprocessor">         memcmp((string1)-&gt;s, (string2)-&gt;s, (string1)-&gt;length) == 0))</span></div>
</div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno">  118</span> </div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno">  121</span><span class="preprocessor">#endif </span><span class="comment">/* COAP_STR_H_ */</span><span class="preprocessor"></span></div>
<div class="ttc" id="agroup__string_html_ga4c283744d0fa51b553bf3fc52488e4b0"><div class="ttname"><a href="group__string.html#ga4c283744d0fa51b553bf3fc52488e4b0">coap_delete_str_const</a></div><div class="ttdeci">void coap_delete_str_const(coap_str_const_t *string)</div><div class="ttdoc">Deletes the given const string and releases any memory allocated.</div><div class="ttdef"><b>Definition</b> <a href="str_8c_source.html#l00047">str.c:47</a></div></div>
<div class="ttc" id="agroup__string_html_ga9862b1ade5e6e2eb01aabd0fa98b63e1"><div class="ttname"><a href="group__string.html#ga9862b1ade5e6e2eb01aabd0fa98b63e1">coap_new_string</a></div><div class="ttdeci">coap_string_t * coap_new_string(size_t size)</div><div class="ttdoc">Returns a new string object with at least size+1 bytes storage allocated.</div><div class="ttdef"><b>Definition</b> <a href="str_8c_source.html#l00018">str.c:18</a></div></div>
<div class="ttc" id="agroup__string_html_gaac769e3d5cea5481436c9eb3cb28d92a"><div class="ttname"><a href="group__string.html#gaac769e3d5cea5481436c9eb3cb28d92a">coap_new_str_const</a></div><div class="ttdeci">coap_str_const_t * coap_new_str_const(const uint8_t *data, size_t size)</div><div class="ttdoc">Returns a new const string object with at least size+1 bytes storage allocated, and the provided data...</div><div class="ttdef"><b>Definition</b> <a href="str_8c_source.html#l00038">str.c:38</a></div></div>
<div class="ttc" id="agroup__string_html_gad991c87cfcf9b2414d2dc430c8701ed3"><div class="ttname"><a href="group__string.html#gad991c87cfcf9b2414d2dc430c8701ed3">coap_delete_string</a></div><div class="ttdeci">void coap_delete_string(coap_string_t *string)</div><div class="ttdoc">Deletes the given string and releases any memory allocated.</div><div class="ttdef"><b>Definition</b> <a href="str_8c_source.html#l00034">str.c:34</a></div></div>
<div class="ttc" id="astructcoap__binary__t_html"><div class="ttname"><a href="structcoap__binary__t.html">coap_binary_t</a></div><div class="ttdoc">Coap binary data definition.</div><div class="ttdef"><b>Definition</b> <a href="str_8h_source.html#l00043">str.h:43</a></div></div>
<div class="ttc" id="astructcoap__binary__t_html_a259ade386451359049875d1d90447963"><div class="ttname"><a href="structcoap__binary__t.html#a259ade386451359049875d1d90447963">coap_binary_t::length</a></div><div class="ttdeci">size_t length</div><div class="ttdoc">length of binary data</div><div class="ttdef"><b>Definition</b> <a href="str_8h_source.html#l00044">str.h:44</a></div></div>
<div class="ttc" id="astructcoap__binary__t_html_a728a24b7e7a462954cdd7a1790c35a8e"><div class="ttname"><a href="structcoap__binary__t.html#a728a24b7e7a462954cdd7a1790c35a8e">coap_binary_t::s</a></div><div class="ttdeci">uint8_t * s</div><div class="ttdoc">binary data</div><div class="ttdef"><b>Definition</b> <a href="str_8h_source.html#l00045">str.h:45</a></div></div>
<div class="ttc" id="astructcoap__str__const__t_html"><div class="ttname"><a href="structcoap__str__const__t.html">coap_str_const_t</a></div><div class="ttdoc">Coap string data definition with const data.</div><div class="ttdef"><b>Definition</b> <a href="str_8h_source.html#l00033">str.h:33</a></div></div>
<div class="ttc" id="astructcoap__str__const__t_html_a9a80ea586c315c518bc345e83d9c852f"><div class="ttname"><a href="structcoap__str__const__t.html#a9a80ea586c315c518bc345e83d9c852f">coap_str_const_t::s</a></div><div class="ttdeci">const uint8_t * s</div><div class="ttdoc">string data</div><div class="ttdef"><b>Definition</b> <a href="str_8h_source.html#l00035">str.h:35</a></div></div>
<div class="ttc" id="astructcoap__str__const__t_html_acab2b62ad139aed3925d34cbf8e3fded"><div class="ttname"><a href="structcoap__str__const__t.html#acab2b62ad139aed3925d34cbf8e3fded">coap_str_const_t::length</a></div><div class="ttdeci">size_t length</div><div class="ttdoc">length of string</div><div class="ttdef"><b>Definition</b> <a href="str_8h_source.html#l00034">str.h:34</a></div></div>
<div class="ttc" id="astructcoap__string__t_html"><div class="ttname"><a href="structcoap__string__t.html">coap_string_t</a></div><div class="ttdoc">Coap string data definition.</div><div class="ttdef"><b>Definition</b> <a href="str_8h_source.html#l00025">str.h:25</a></div></div>
<div class="ttc" id="astructcoap__string__t_html_ad904e545a40c835079a1eb2dd230fb29"><div class="ttname"><a href="structcoap__string__t.html#ad904e545a40c835079a1eb2dd230fb29">coap_string_t::s</a></div><div class="ttdeci">uint8_t * s</div><div class="ttdoc">string data</div><div class="ttdef"><b>Definition</b> <a href="str_8h_source.html#l00027">str.h:27</a></div></div>
<div class="ttc" id="astructcoap__string__t_html_adbca4bb782ba6046520f8608ef0f5a66"><div class="ttname"><a href="structcoap__string__t.html#adbca4bb782ba6046520f8608ef0f5a66">coap_string_t::length</a></div><div class="ttdeci">size_t length</div><div class="ttdoc">length of string</div><div class="ttdef"><b>Definition</b> <a href="str_8h_source.html#l00026">str.h:26</a></div></div>
<div class="ttc" id="authash_8h_html_aba7bc1797add20fe3efdf37ced1182c5"><div class="ttname"><a href="uthash_8h.html#aba7bc1797add20fe3efdf37ced1182c5">uint8_t</a></div><div class="ttdeci">unsigned char uint8_t</div><div class="ttdef"><b>Definition</b> <a href="uthash_8h_source.html#l00079">uthash.h:79</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_a14d23a24002734ac2a3b997119f008e.html">coap2</a></li><li class="navelem"><a class="el" href="str_8h.html">str.h</a></li>
    <li class="footer">Generated on Fri Dec 27 2024 09:57:44 for libcoap by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8 </li>
  </ul>
</div>
</body>
</html>
